

function ComDataTable(url, target,column_id) {
    this.$serverurl = url;
    this.$target = target;
    this.$columnid  = column_id;
    _tarObject = this;
}
ComDataTable.prototype.setRenders = function(renders){
    this.$renders = renders;
}
ComDataTable.prototype.initRenders = function(){
    //初始化columns的格式化列
    if(this.$renders){
        for(i=0;i<_tarObject.$columns.length;i++){
            if(this.$renders[_tarObject.$columns[i].data]){
                _tarObject.$columns[i].render = this.$renders[_tarObject.$columns[i].data];
            }
        }
    }
}
ComDataTable.prototype.rdraw = function(){
    this.$table.draw();
}
ComDataTable.prototype.initColumns = function(){

    //获取对应的columns配置信息
    this.$columns =  language.getColumns(this.$columnid);
    //组装table的header内容区域
    var header="<thead><tr>";
    for(i=0;i<this.$columns.length;i++){
        header +=  "<td>"+this.$columns[i].name+"</td>";
    }
    header += "</tr></thead>";

    this.$target.append(header);
}
ComDataTable.prototype.init = function(){
    this.initColumns();
    this.initRenders();
    this.$table = this.$target.DataTable({
        "processing": true,
        "serverSide": true,
        "ordering": false,
        "searching": false,
        //"sScrollX":true,
        "fnServerData": this.retrieveData,
        //"dom":  '<"top"i>rt<"bottom"flp> ',
        "columns": _tarObject.$columns,
        "oLanguage":language.getTabLanguage(),
    });
}

ComDataTable.prototype.retrieveData = function( sSource, aoData, fnCallback ) {
    //将客户名称加入参数数组
    aoData.push( { "name": "customerName", "value": $("#customerName").val() } );
    //console.log(aoData);
    $.ajax( {
        "type": "POST",
        "contentType": "application/json",
        "url": _tarObject.$serverurl,
        "dataType": "json",
        //"data":aoData, //以json格式传递
        "data": JSON.stringify(aoData), //以json格式传递
        "success": function(resp) {
            fnCallback(resp.res_data); //服务器端返回的对象的returnObject部分是要求的格式
        }
    });
}